package cn.group.service.impl;

import cn.group.mapper.GoodsMapper;
import cn.group.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.entity.Good;
import utils.GetGoods;

import java.util.ArrayList;
import java.util.List;

@Service
public class GoodServiceImpl implements GoodService {

    @Autowired
    GoodsMapper goodsMapper;

    @Override
    public List<Good> getURLMassage(String title, String page){
        GetGoods getGoods = new GetGoods();
        ArrayList<Good> goodList = getGoods.getMassage(title, page);
        return goodList;
    }

    @Override
    public void addGood(Good good) {
        goodsMapper.addGoods(good);
    }

    @Override
    public void deleteGood(Long goodId) {
        goodsMapper.deleteGood(goodId);
    }

    @Override
    public void updateUp(Long goodId) {
        goodsMapper.updateUp(goodId);
    }

    @Override
    public void updateDown(Long goodId) {
        goodsMapper.updateDown(goodId);
    }

    @Override
    public List<Good> findAllGoods() {
        List<Good> allGoods = goodsMapper.findAllGoods();
        return allGoods;
    }

    @Override
    public Good findGood(Good good) {
        Good go = goodsMapper.findGood(good);
        return go;
    }

    @Override
    public List<Good> selectByName(String key) {
        List<Good> goods = goodsMapper.selectByName(key);
        return goods;
    }
}
